home *** CD-ROM | disk | FTP | other *** search
-
- TTY(4) UNIX Programmer's Manual TTY(4)
-
- NNAAMMEE
- ttttyy - general terminal interface
-
- SSYYNNOOPPSSIISS
- ##iinncclluuddee <<ssyyss//iiooccttll..hh>>
-
- DDEESSCCRRIIPPTTIIOONN
- This section describes the interface to the terminal drivers in the sys-
- tem.
-
- TTeerrmmiinnaall SSppeecciiaall FFiilleess
- Each hardware terminal port on the system usually has a terminal special
- device file associated with it in the directory ``/dev/'' (for example,
- ``/dev/tty03''). When a user logs into the system on one of these hard-
- ware terminal ports, the system has already opened the associated device
- and prepared the line for normal interactive use (see getty(8).) There
- is also a special case of a terminal file that connects not to a hardware
- terminal port, but to another program on the other side. These special
- terminal devices are called _p_t_y_s and provide the mechanism necessary to
- give users the same interface to the system when logging in over a net-
- work (using rlogin(1), or telnet(1) for example.) Even in these cases
- the details of how the terminal file was opened and set up is already
- handled by special software in the system. Thus, users do not normally
- need to worry about the details of how these lines are opened or used.
- Also, these lines are often used for dialing out of a system (through an
- out-calling modem), but again the system provides programs that hide the
- details of accessing these terminal special files (see tip(2).)
-
- When an interactive user logs in, the system prepares the line to behave
- in a certain way (called a _l_i_n_e _d_i_s_c_i_p_l_i_n_e), the particular details of
- which is described in stty(1) at the command level, and in termios(4) at
- the programming level. A user may be concerned with changing settings
- associated with his particular login terminal and should refer to the
- preceding man pages for the common cases. The remainder of this man page
- is concerned with describing details of using and controlling terminal
- devices at a low level, such as that possibly required by a program wish-
- ing to provide features similar to those provided by the system.
-
- LLiinnee ddiisscciipplliinneess
- A terminal file is used like any other file in the system in that it can
- be opened, read, and written to using standard system calls. For each
- existing terminal file, there is a software processing module called a
- _l_i_n_e _d_i_s_c_i_p_l_i_n_e is associated with it. The _l_i_n_e _d_i_s_c_i_p_l_i_n_e essentially
- glues the low level device driver code with the high level generic inter-
- face routines (such as read(2) and write(2)), and is responsible for im-
- plementing the semantics associated with the device. When a terminal
- file is first opened by a program, the default _l_i_n_e _d_i_s_c_i_p_l_i_n_e called the
- termios line discipline is associated with the file. This is the primary
- line discipline that is used in most cases and provides the semantics
- that users normally associate with a terminal. When the termios line
- discipline is in effect, the terminal file behaves and is operated ac-
- cording to the rules described in termios(4). Please refer to that man
- page for a full description of the terminal semantics. The operations
- described here generally represent features common across all _l_i_n_e
- _d_i_s_c_i_p_l_i_n_e_s, however some of these calls may not make sense in conjunc-
- tion with a line discipline other than termios, and some may not be sup-
- ported by the underlying hardware (or lack thereof, as in the case of
- ptys).
-
- TTeerrmmiinnaall FFiillee OOppeerraattiioonnss
- All of the following operations are invoked using the ioctl(2) system
- call. Refer to that man page for a description of the _r_e_q_u_e_s_t and _a_r_g_p
- parameters. In addition to the ioctl _r_e_q_u_e_s_t_s defined here, the specific
- line discipline in effect will define other _r_e_q_u_e_s_t_s specific to it (ac-
- tually termios(4) defines them as function calls, not ioctl _r_e_q_u_e_s_t_s.)
- The following section lists the available ioctl requests. The name of
- the request, a description of its purpose, and the typed _a_r_g_p parameter
- (if any) are listed. For example, the first entry says
-
- _T_I_O_C_S_E_T_D _i_n_t _*_l_d_i_s_c
-
- and would be called on the terminal associated with file descriptor zero
- by the following code fragment:
-
- int ldisc;
-
- ldisc = TTYDISC;
- ioctl(0, TIOCSETD, &ldisc);
-
- TTeerrmmiinnaall FFiillee RReeqquueesstt DDeessccrriippttiioonnss
-
- TIOCSETD _i_n_t _*_l_d_i_s_c
- Change to the new line discipline pointed to by _l_d_i_s_c. The
- available line disciplines are listed in <sys/termios.h> and
- currently are:
-
- TTYDISC Termios interactive line discipline.
- TABLDISC Tablet line discipline.
- SLIPDISC Serial IP line discipline.
-
- TIOCGETD _i_n_t _*_l_d_i_s_c
- Return the current line discipline in the integer pointed to
- by _l_d_i_s_c.
-
- TIOCSBRK _v_o_i_d
- Set the terminal hardware into BREAK condition.
-
- TIOCCBRK _v_o_i_d
- Clear the terminal hardware BREAK condition.
-
- TIOCSDTR _v_o_i_d
- Assert data terminal ready (DTR).
-
- TIOCCDTR _v_o_i_d
- Clear data terminal ready (DTR).
-
- TIOCGPGRP _i_n_t _*_t_p_g_r_p
- Return the current process group the terminal is associated
- with in the integer pointed to by _t_p_g_r_p. This is the underly-
- ing call that implements the termios(4) ttccggeettaattttrr() call.
-
- TIOCSPGRP _i_n_t _*_t_p_g_r_p
- Associate the terminal with the process group (as an integer)
- pointed to by _t_p_g_r_p. This is the underlying call that imple-
- ments the termios(4) ttccsseettaattttrr() call.
-
- TIOCGETA _s_t_r_u_c_t _t_e_r_m_i_o_s _*_t_e_r_m
- Place the current value of the termios state associated with
- the device in the termios structure pointed to by _t_e_r_m. This
- is the underlying call that implements the termios(4)
- ttccggeettaattttrr() call.
-
- TIOCSETA _s_t_r_u_c_t _t_e_r_m_i_o_s _*_t_e_r_m
- Set the termios state associated with the device immediately.
- This is the underlying call that implements the termios(4)
- ttccsseettaattttrr() call with the TCSANOW option.
-
- TIOCSETAW _s_t_r_u_c_t _t_e_r_m_i_o_s _*_t_e_r_m
- First wait for any output to complete, then set the termios
- state associated with the device. This is the underlying
- call that implements the termios(4) ttccsseettaattttrr() call with the
- TCSADRAIN option.
-
- TIOCSETAF _s_t_r_u_c_t _t_e_r_m_i_o_s _*_t_e_r_m
- First wait for any output to complete, clear any pending in-
- put, then set the termios state associated with the device.
- This is the underlying call that implements the termios(4)
- ttccsseettaattttrr() call with the TCSAFLUSH option.
-
- TIOCOUTQ _i_n_t _*_n_u_m
- Place the current number of characters in the output queue in
- the integer pointed to by _n_u_m.
-
- TIOCSTI _c_h_a_r _*_c_p
- Simulate typed input. Pretend as if the terminal received
- the character pointed to by _c_p.
-
- TIOCNOTTY _v_o_i_d
- This call is obsolete but left for compatibility. In the
- past, when a process that didn't have a controlling terminal
- (see _T_h_e _C_o_n_t_r_o_l_l_i_n_g _T_e_r_m_i_n_a_l in termios(4)) first opened a
- terminal device, it acquired that terminal as its controlling
- terminal. For some programs this was a hazard as they didn't
- want a controlling terminal in the first place, and this pro-
- vided a mechanism to disassociate the controlling terminal
- from the calling process. It _m_u_s_t be called by opening the
- file _/_d_e_v_/_t_t_y and calling TIOCNOTTY on that file descriptor.
-
- The current system does not allocate a controlling terminal
- to a process on an ooppeenn() call: there is a specific ioctl
- called TIOSCTTY to make a terminal the controlling terminal.
- In addition, a program can ffoorrkk() and call the sseettssiidd() sys-
- tem call which will place the process into its own session -
- which has the effect of disassociating it from the control-
- ling terminal. This is the new and preferred method for pro-
- grams to lose their controlling terminal.
-
- TIOCSTOP _v_o_i_d
- Stop output on the terminal (like typing ^S at the keyboard).
-
- TIOCSTART _v_o_i_d
- Start output on the terminal (like typing ^Q at the key-
- board).
-
- TIOCSCTTY _v_o_i_d
- Make the terminal the controlling terminal for the process
- (the process must not currently have a controlling terminal).
-
- TIOCDRAIN _v_o_i_d
- Wait until all output is drained.
-
- TIOCEXCL _v_o_i_d
- Set exclusive use on the terminal. No further opens are per-
- mitted except by root. Of course, this means that programs
- that are run by root (or setuid) will not obey the exclusive
- setting - which limits the usefulness of this feature.
-
- TIOCNXCL _v_o_i_d
- Clear exclusive use of the terminal. Further opens are per-
- mitted.
-
- TIOCFLUSH _i_n_t _*_w_h_a_t
- If the value of the int pointed to by _w_h_a_t contains the FREAD
- bit as defined in <sys/file.h>, then all characters in the
- input queue are cleared. If it contains the FWRITE bit, then
- all characters in the output queue are cleared. If the value
- of the integer is zero, then it behaves as if both the FREAD
- and FWRITE bits were set (i.e. clears both queues).
-
- TIOCGWINSZ _s_t_r_u_c_t _w_i_n_s_i_z_e _*_w_s
- Put the window size information associated with the terminal
- in the _w_i_n_s_i_z_e structure pointed to by _w_s. The window size
- structure contains the number of rows and columns (and pixels
- if appropriate) of the devices attached to the terminal. It
- is set by user software and is the means by which most full-
- screen oriented programs determine the screen size. The
- _w_i_n_s_i_z_e structure is defined in <sys/ioctl.h>.
-
- TIOCSWINSZ _s_t_r_u_c_t _w_i_n_s_i_z_e _*_w_s
- Set the window size associated with the terminal to be the
- value in the _w_i_n_s_i_z_e structure pointed to by _w_s (see above).
-
- TIOCCONS _i_n_t _*_o_n
- If _o_n points to a non-zero integer, redirect kernel console
- output (kernel printf's) to this terminal. If _o_n points to a
- zero integer, redirect kernel console output back to the nor-
- mal console. This is usually used on workstations to redi-
- rect kernel messages to a particular window.
-
- TIOCMSET _i_n_t _*_s_t_a_t_e
- The integer pointed to by _s_t_a_t_e contains bits that correspond
- to modem state. Following is a list of defined variables and
- the modem state they represent:
-
- TIOCM_LE Line Enable.
- TIOCM_DTR Data Terminal Ready.
- TIOCM_RTS Request To Send.
- TIOCM_ST Secondary Transmit.
- TIOCM_SR Secondary Receive.
- TIOCM_CTS Clear To Send.
- TIOCM_CAR Carrier Detect.
- TIOCM_CD Carier Detect (synonym).
- TIOCM_RNG Ring Indication.
- TIOCM_RI Ring Indication (synonym).
- TIOCM_DSR Data Set Ready.
-
- This call sets the terminal modem state to that represented
- by _s_t_a_t_e. Not all terminals may support this.
-
- TIOCMGET _i_n_t _*_s_t_a_t_e
- Return the current state of the terminal modem lines as rep-
- resented above in the integer pointed to by _s_t_a_t_e.
-
- TIOCMBIS _i_n_t _*_s_t_a_t_e
- The bits in the integer pointed to by _s_t_a_t_e represent modem
- state as described above, however the state is OR-ed in with
- the current state.
-
- TIOCMBIC _i_n_t _*_s_t_a_t_e
- The bits in the integer pointed to by _s_t_a_t_e represent modem
- state as described above, however each bit which is on in
- _s_t_a_t_e is cleared in the terminal.
-
- SSEEEE AALLSSOO
- getty(8), ioctl(2), pty(4), stty(1), termios(4)
-
- 4th Berkeley Distribution August 14, 1992 4
-